var tmRobin; var md=new MobileDetect(window.navigator.userAgent); (function($){ "use strict"; tmRobin=( function (){ var $window=$(window), $document=$(document), $body=$('body'); return { init: function (){ this.stickyHeader(); this.scrollToTop(); this.blog(); this.switcher(); this.siteMenu(); this.mobileMenu(); this.search(); this.wishlist(); this.miniCart(); this.shop(); this.quickView(); this.notification(); this.compare(); this.ajaxAddToCart(); this.ajaxLoadMore(); this.product(); this.crossSells(); this.swatches(); this.quantityField(); this.imageCarousel(); this.testimonialCarousel(); this.countdown(); this.productCategoriesShortcode(); this.productsShortCode(); this.vcTabs(); this.vcRow(); this.cookie(); this.brand (); }, stickyHeader: function (){ if(!tmRobinConfigs.sticky_header){ return; } var $header=$('.site-header'); if(!$header.length){ return; } var $topBar=$('.topbar'), $logo=$header.find('.site-logo'), $menu=$header.find('.site-menu'), $tools=$header.find('.header-tools'), startOffset=$header.outerHeight(); var stickyHeaderHTML=''; $header.before(stickyHeaderHTML); var $stickyHeader=$('.sticky-header'); if($logo.length){ var $img=$stickyHeader.find('.site-logo img'); if($img.length){ var o_logo=$img.attr('data-o_logo'); if(typeof o_logo!=='undefined'){ $img.attr('src', o_logo); }} } if($topBar.length){ startOffset +=$topBar.outerHeight() - 30; } if($('#wpadminbar').length){ startOffset +=$('#wpadminbar').outerHeight(); } $window.scroll(function (){ var currentScroll=$(this).scrollTop(), $realTools=$('.site-header:not(.sticky-header)').find('.header-tools'), $stickyTools=$stickyHeader.find('.header-tools'); if(currentScroll > startOffset){ $stickyHeader.addClass('is-sticky'); $header.addClass('real-header'); $realTools.find('>div') .appendTo('.site-header.sticky-header > .container > .row > .header-tools'); }else{ $stickyTools.find('>div') .appendTo('.site-header.real-header > .container > .row > .header-tools'); $stickyHeader.removeClass('is-sticky'); $header.removeClass('real-header'); }}); $window.scroll(); }, scrollToTop: function (){ var $scrollToTop=$('.scroll-to-top'); $window.scroll(function (){ if($window.scrollTop() > 100){ $scrollToTop.addClass('show'); }else{ $scrollToTop.removeClass('show'); }}); $scrollToTop.on('click', function(e){ e.preventDefault(); $('body, html').animate({ scrollTop: 0 }, 600); }); }, fitVideo: function (){ $('.container').fitVids(); }, thumbGallery: function (){ if($('.post-gallery > .slider .single-image').length){ $('.post-gallery > .slider').slick({ slidesToShow:1, arrows:true, dots:false, infinite:true, adaptiveHeight: true, }); $('.single-image:not(.slick-cloned)').magnificPopup({ delegate: 'a', gallery:{ enabled: true, }, type:'image', }); }}, blog: function (){ var blogMasonry=function (){ if(typeof( $.fn.isotope )==='undefined'||typeof( $.fn.imagesLoaded )==='undefined'){ return; } var $container=$('.masonry-container'); $container.imagesLoaded(function (){ $container.isotope({ gutter:0, itemSelector: '.post-teaser--masonry, .masonry-item', }); }); }; var postsSlider=function (){ $('.js-post-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts===null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ slidesToShow:parseInt(atts.columns), slidesToScroll: parseInt(atts.columns), adaptiveHeight: true, infinite:atts.loop==='yes', autoplay:atts.auto_play==='yes', autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, prevArrow:'', nextArrow:'', responsive:[ { breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, }, }, { breakpoint: 769, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'30px', slidesToShow:1, slidesToScroll: 1, }, }, ], }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.slick(configs); setTimeout(function (){ var $thumbGallery=$this.find('.post-gallery > .slider'); $thumbGallery.each(function (){ if(typeof $(this).get(0).slick!='undefined'){ $(this).get(0).slick.setPosition(); }}); }, 1000); }); }; var blogShortcode=function (){ var $posts=$('.tm-robin-blog .posts'), masonryConfig={ itemSelector:'.post-item', transitionDuration: 400, }; if($posts.hasClass('post-carousel-layout')){ return; }else if($posts.hasClass('post-grid-layout')){ masonryConfig['layoutMode']='fitRows'; } $posts.isotope(masonryConfig).imagesLoaded(function (){ $posts.isotope('layout'); }); }; tmRobin.fitVideo(); tmRobin.thumbGallery(); blogMasonry(); postsSlider(); blogShortcode(); }, switcher: function (){ var $languageSwitcher=$('.language-switcher select'), $currencySwitcher=$('.currency-switcher select'), $WOOCSCurrencySwitcher=$('.currency-switcher.woocs-switcher'), $WPMLCurrencySwitcher=$('.currency-switcher.wcml-switcher'); var loadCurrency=function(currency){ $.ajax({ type:'post', url:tmShopieConfigs.ajax_url, data:{ action:'wcml_switch_currency', currency: currency, }, success: function (){ window.location=window.location.href; }, error:function(error){ console.log(error); }, }); }; var WOOCSSwitcher=function (){ $('.option', $WOOCSCurrencySwitcher).on('click', function (){ $WPMLCurrencySwitcher.addClass('loading'); var $this=$(this); $('.currency-switcher').addClass('loading'); setTimeout(function (){ window.location=$this.attr('data-value'); }, 500); }); }; var wooWPMLSwitcher=function (){ $('.option', $WPMLCurrencySwitcher).on('click', function (){ $WPMLCurrencySwitcher.addClass('loading'); var currency=$(this).find('.option').attr('data-value'); loadCurrency(currency); }); }; if($('option', $languageSwitcher).length){ $languageSwitcher.niceSelect(); var $niceSelect=$languageSwitcher.next('.nice-select'), imgSrc=$languageSwitcher.find(':selected').attr('data-imagesrc'); if(typeof imgSrc!='undefined'){ $niceSelect.find('span.current').prepend(''); } $languageSwitcher.find('option').each(function (){ imgSrc=$(this).attr('data-imagesrc'); var index=$(this).index(); if(typeof imgSrc!=='undefined'){ $niceSelect.find('.option') .eq(index) .prepend(''); }}); $body.on('click', '.language-switcher .nice-select .option', function (){ var $this=$(this); $('.language-switcher').addClass('loading'); setTimeout(function (){ window.location=$this.attr('data-value'); }, 500); }); } if($('option', $currencySwitcher).length){ $currencySwitcher.niceSelect(); WOOCSSwitcher(); wooWPMLSwitcher(); }}, siteMenu: function (){ var $siteMenu=$('.site-menu'); if(!$siteMenu.length){ return; } var $customMegaMenu=$siteMenu.find('li.mega-menu-custom'), $normalMegaMenu=$siteMenu.find('li.menu-item:not(.mega-menu)'), pageContainerRect=$('#page-container')[0].getBoundingClientRect(), screenWidth=$window.width(), viewportWidth=$body.hasClass('body-boxed') ? pageContainerRect.right:screenWidth; var megaMenuOffsets=function (){ if(md.mobile()||md.phone()||md.tablet()){ return; } if(!$customMegaMenu.length){ return; } $customMegaMenu.on('hover', function (){ setOffset($(this)); }).each(function (){ setOffset($(this)); }); }; var normalMenuHoverBack=function (){ if(md.mobile()||md.phone()||md.tablet()){ return; } $normalMegaMenu.on('hover', function (){ hoverBackInit($(this)); }).each(function (){ hoverBackInit($(this)); }); }; var defaultMegaMenu=function (){ if($body.hasClass('error404')){ return; } var mainContainerRect=$body.hasClass('single-product') ? $('.site-content > .product > .container')[0].getBoundingClientRect():$('.main-container > .container')[0].getBoundingClientRect(), leftOffset=$body.hasClass('body-boxed') ? 15:mainContainerRect.left + 15; if(!md.mobile()&&!md.phone()&&!md.tablet()){ $siteMenu.find('.mega-menu-default').each(function (){ $(this).find('>.sub-menu').css({ 'width': mainContainerRect.width - 30, 'left':leftOffset, }); }); }}; var fullWidthMegaMenu=function (){ if($body.hasClass('error404')){ return; } var left=$siteMenu[0].getBoundingClientRect().left, w=$body.hasClass('body-boxed') ? $('#page-container')[0].getBoundingClientRect().right:$window.width(); $siteMenu.find('.mega-menu-full-width').each(function (){ $(this).find('>.sub-menu').css({ 'width': w, 'left':0 - left, }); }); }; var isOutSide=function($li){ var subMenu=$li.find('>.sub-menu'); if(typeof subMenu[0]=='undefined'){ return; } var subMenuRect=subMenu[0].getBoundingClientRect(); return subMenuRect.right >=viewportWidth; }; var setOffset=function($li){ if(isOutSide($li)){ var $subMenu=$li.find('>.sub-menu'), subMenuRect=$subMenu[0].getBoundingClientRect(), sub=subMenuRect.right - pageContainerRect.right; $subMenu.css({ left: -sub - 15, }); }}; var hoverBackInit=function($li){ if(isOutSide($li)){ var $subMenu=$('>.sub-menu', $li); if(!$subMenu.hasClass('hover-back')){ $li.addClass('has-hover-back'); $subMenu.addClass('hover-back'); $('.sub-menu', $subMenu).addClass('hover-back'); }else{ $li.removeClass('has-hover-back'); $subMenu.removeClass('hover-back'); $('.sub-menu', $subMenu).removeClass('hover-back'); }} }; megaMenuOffsets(); normalMenuHoverBack(); defaultMegaMenu(); fullWidthMegaMenu(); $window.on('resize', function (){ megaMenuOffsets(); normalMenuHoverBack(); defaultMegaMenu(); fullWidthMegaMenu(); }); }, setTopValue: function($el){ var $adminBar=$('#wpadminbar'), w=$window.width(), h=$adminBar.height(), top=h; if($adminBar.length){ if($adminBar.css('position')=='absolute'&&w <=600){ var t=$adminBar[0].getBoundingClientRect().top; top=( t >=0 - h ) ? h + t:0; }} if(w >=1200){ return; } $el.css('top', top); }, mobileMenu: function (){ var $mobileBtn=$('.mobile-menu-btn'), $mobileMenu=$('#site-mobile-menu'), $mobileMenuClz=$('.site-mobile-menu'), $pageContainer=$('#page-container'); var caculateRealHeight=function($ul){ var height=0; $ul.find('>li').each(function (){ height +=$(this).outerHeight(); }); return height; }; var setUpOverflow=function(h1, h2){ if(h1 < h2){ $mobileMenuClz.css('overflow-y', 'hidden'); }else{ $mobileMenuClz.css('overflow-y', 'auto'); }}; var buildSlideOut=function (){ if(typeof $mobileMenu!=='undefined'&&typeof $pageContainer!=='undefined'){ $body.on('click', '.mobile-menu-btn', function (){ $(this).toggleClass('is-active'); $(this).find('> .hamburger').toggleClass('is-active'); $body.toggleClass('mobile-menu-opened'); tmRobin.setTopValue($mobileMenuClz); }); $pageContainer.on('click touchstart', function(e){ if(!$(e.target).closest('.mobile-menu-btn').length){ if($body.hasClass('mobile-menu-opened')){ $body.removeClass('mobile-menu-opened'); $mobileBtn.removeClass('is-active'); $mobileBtn.find('> .hamburger').removeClass('is-active'); $mobileMenu.find('#searchform input[type="text"]').blur(); e.preventDefault(); }} }); setUpOverflow($mobileMenu.height(), $mobileMenuClz.height()); }}; var buildDrillDown=function (){ var level=0, opener='open', height=$mobileMenuClz.height(); $mobileMenu.find('li:has(ul)').each(function (){ var $this=$(this), allLink=$this.find('> a').clone(); if(allLink.length){ $this.prepend(opener); $this.find('> ul') .prepend(''); }}); $mobileMenu.on('click', '.open-child', function (){ var $parent=$(this).parent(); if($parent.hasClass('over')){ $parent.removeClass('over'); level--; if(level==0){ setUpOverflow($mobileMenu.height(), height); }}else{ $parent.parent().find('>li.over').removeClass('over'); $parent.addClass('over'); level++; setUpOverflow(caculateRealHeight($parent.find('>.sub-menu')), height); } $mobileMenu.parent().scrollTop(0); }); $mobileMenu.on('click', '.menu-back', function (){ var $grand=$(this).parent().parent(); if($grand.hasClass('over')){ $grand.removeClass('over'); level--; if(level==0){ setUpOverflow($mobileMenu.height(), height); }} $mobileMenu.parent().scrollTop(0); }); }; buildSlideOut(); buildDrillDown(); $window.on('resize', function (){ tmRobin.setTopValue($mobileMenuClz); }); }, search: function (){ var $search=$('.header-search'), $dropDownWrapper=$search.find('.search-dropdown-wrapper'), $form=$('form.ajax-search-form'), $select=$search.find('select.search-select'), $input=$search.find('input.search-input'), $ajaxNotice=$('.ajax-search-notice'), noticeText=$ajaxNotice.text(), found=false; if(!$search.length){ return; } var categoriesSelectBox=function (){ if($select.find('>option').length){ $select.select2({ templateResult: function(str){ if(!str.id){ return str.text; } return $('' + str.text + ''); }, }).on('change', function (){ var text=$(this) .find('option[value="' + $(this).val() + '"]') .text() .trim(); $('#select2-product_cat-container').text(text); $('#select2-cat-container').text(text); setTimeout(function (){ $input.focus(); }, 500); ajaxSearch(); }); $select.next('.select2').on('mousedown', function (){ $('#select2-product_cat-results').perfectScrollbar(); }); }}; var events=function (){ $search.each(function (){ var $this=$(this); $this.find('.search-widget-area section.widget').perfectScrollbar(); $this.on('click', '> .toggle', function(e){ e.preventDefault(); if(!$this.hasClass('search-open')){ openSearch($this); }else{ closeSearch($this); }}); }); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.header-search'); if(!$target.length){ closeSearch(); }}); $input.on('keyup', function(event){ if(event.altKey||event.ctrlKey||event.shiftKey||event.metaKey){ return; } var keys=[ 9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 39, 45, 46, ]; if(keys.indexOf(event.keyCode)!=-1){ return; } if($dropDownWrapper.hasClass('only-results')){ if($(this).val().length){ $dropDownWrapper.slideDown(); }} switch(event.which){ case 8: if($(this).val().length < tmRobinConfigs.search_min_chars){ $('.autocomplete-suggestion').remove(); $('.search-view-all').remove(); $ajaxNotice.fadeIn(200).text(noticeText); } break; case 27: if($(this).val()==''){ closeSearch($(this).closest('.header-search')); } $('.autocomplete-suggestion').remove(); $('.search-view-all').remove(); $(this).val(''); $ajaxNotice.fadeIn(200).text(noticeText); break; default: break; }}); }; var ajaxSearch=function (){ var productCat='0', cat='0', symbol=tmRobinConfigs.ajax_url.split('?')[1] ? '&':'?', postType=$form.find('input[name="post_type"]').val(), url=tmRobinConfigs.ajax_url + symbol + 'action=tm_robin_ajax_search'; if($select.find('option').length){ productCat=cat=$select.val(); } if(postType=='product'){ url +='&product_cat=' + productCat; }else{ url +='&cat=' + cat; } url +='&limit=' + tmRobinConfigs.search_limit; $input.devbridgeAutocomplete({ serviceUrl:url, minChars:tmRobinConfigs.search_min_chars, appendTo:$('.ajax-results-wrapper'), deferRequestBy:300, beforeRender:function(container){ container.perfectScrollbar(); }, onSelect:function(suggestion){ if(suggestion.url.length){ window.location.href=suggestion.url; } if(suggestion.id==-2){ return; }}, onSearchStart:function (){ $search.addClass('search-loading'); }, onSearchComplete: function(query, suggestions){ $search.removeClass('search-loading'); if(found&&suggestions[0].id!=-1){ $ajaxNotice.fadeOut(200); }else{ $ajaxNotice.fadeIn(200); } if(suggestions.length > 1&&suggestions[suggestions.length - 1].id==-2){ var viewAll=suggestions[suggestions.length - 1]; $search.find('.autocomplete-suggestions') .append('' + viewAll.value + ''); } $('.autocomplete-suggestion').each(function (){ if(!$(this).html()){ $(this).remove(); }}); }, formatResult:function(suggestion, currentValue){ return generateHTML(suggestion, currentValue); }, }); }; var generateHTML=function(suggestion, currentValue){ var postType=$form.find('input[name="post_type"]').val(), pattern='(' + escapeRegExChars(currentValue) + ')', returnValue=''; if(suggestion.id==-1){ $ajaxNotice.text(suggestion.value).fadeIn(200); return returnValue; } if(suggestion.id==-2){ return returnValue; } found=true; if(suggestion.thumbnail){ returnValue +='
' + suggestion.thumbnail + '
'; } if(suggestion.id!=-2){ returnValue +='
'; } var title=suggestion.value.replace(new RegExp(pattern, 'gi'), '$1<\/ins>') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/<(\/?ins)>/g, '<$1>') + ''; if(suggestion.url.length){ returnValue += '' + title + ''; }else{ returnValue +='
' + title + '
'; } if(postType==='product'){ var sku=suggestion.sku; if(tmRobinConfigs.search_by=='sku'||tmRobinConfigs.search_by=='both'){ sku=suggestion.sku.replace(new RegExp(pattern, 'gi'), '$1<\/ins>') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/<(\/?ins)>/g, '<$1>') + ''; } console.log(sku); if(suggestion.sku){ returnValue +='SKU: ' + sku + ''; } if(suggestion.price){ returnValue +='' + suggestion.price + ''; }} if(postType==='post'){ if(suggestion.date){ returnValue +='' + suggestion.date + ''; }} if(suggestion.excerpt&&tmRobinConfigs.search_excerpt_on){ returnValue +='

' + suggestion.excerpt + '

'; } if(suggestion.id!=-2){ returnValue +='
'; } return returnValue; }; var escapeRegExChars=function(value){ return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); }; categoriesSelectBox(); events(); ajaxSearch(); var openSearch=function($el){ if(md.mobile()||md.phone()||md.tablet()||$search.hasClass('search-full-screen')){ $body.addClass('mobile-search-opened'); } $el.addClass('search-open'); $el.find('.search-form-wrapper').fadeIn(200); $el.find('input[type="text"]').focus(); }; var closeSearch=function($el){ if(md.mobile()||md.phone()||md.tablet()||$search.hasClass('search-full-screen')){ $body.removeClass('mobile-search-opened'); } if(typeof $el=='undefined'){ $search.removeClass('search-open'); $search.find('.search-form-wrapper').fadeOut(200); $search.find('input[type="text"]').blur(); }else{ $el.removeClass('search-open'); $el.find('.search-form-wrapper').fadeOut(200); $el.find('input[type="text"]').blur(); } if($dropDownWrapper.hasClass('only-results')){ $dropDownWrapper.slideUp(); }};}, wishlist: function (){ var $wishlist=$('.header-wishlist'), $dropDown=$wishlist.find('.wishlist-dropdown-wrapper'), itemsCount=0, removeImmediately=false, undoTimeout, deletedItems=[]; if(!$wishlist.length){ return; } var wlFragments=function (){ var $supports_html5_storage, wl_hash_key='tm_robin_wl_hash', fragment_name='tm_robin_wl_fragments'; try { $supports_html5_storage=( 'sessionStorage' in window&&window.sessionStorage!==null ); window.sessionStorage.setItem('tm_robin', 'test'); window.sessionStorage.removeItem('tm_robin'); window.localStorage.setItem('tm_robin', 'test'); window.localStorage.removeItem('tm_robin'); } catch(err){ $supports_html5_storage=false; } function set_wl_creation_timestamp(){ if($supports_html5_storage){ sessionStorage.setItem('tm_robin_wl_created', ( new Date() ).getTime()); }} function set_wl_hash(wl_hash){ if($supports_html5_storage){ localStorage.setItem(wl_hash_key, wl_hash); sessionStorage.setItem(wl_hash_key, wl_hash); }} var $fragment_refresh={ url:tmRobinConfigs.ajax_url, type:'GET', data:{ action: 'tm_robin_get_wishlist_fragments', }, success: function(data){ if(data&&data.fragments){ $.each(data.fragments, function(key, value){ $(key).replaceWith(value); }); if($supports_html5_storage){ sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments)); set_wl_hash(data.wl_hash); if(data.wl_hash){ set_wl_creation_timestamp(); }} $(document.body).trigger('wl_fragments_refreshed'); }}, error:function(error){ console.log(error); }, }; function refresh_wl_fragment(){ $.ajax($fragment_refresh); } if($supports_html5_storage){ var wl_timeout=null, day_in_ms=24 * 60 * 60 * 1000; $(document.body).bind('wl_fragment_refresh updated_wc_div', function (){ refresh_wl_fragment(); }); $(document.body) .bind('added_to_wishlist removed_from_wishlist', function(event, fragments, cart_hash){ var prev_wl_hash=sessionStorage.getItem(wl_hash_key); if(prev_wl_hash===null||prev_wl_hash===undefined||prev_wl_hash===''){ set_wl_creation_timestamp(); } sessionStorage.setItem(fragment_name, JSON.stringify(fragments)); refresh_wl_fragment(); }); $(document.body).bind('wl_fragments_refreshed', function (){ clearTimeout(wl_timeout); wl_timeout=setTimeout(refresh_wl_fragment, day_in_ms); }); $window.on('storage onstorage', function(e){ if(wl_hash_key===e.originalEvent.key&&localStorage.getItem(wl_hash_key)!==sessionStorage.getItem(wl_hash_key)){ refresh_wl_fragment(); }}); try { var wl_fragments=JSON.parse(sessionStorage.getItem(fragment_name)), wl_hash=sessionStorage.getItem(wl_hash_key), cookie_hash=Cookies.set('tm_robin_wl_hash'), wl_created=sessionStorage.getItem('tm_robin_wl_created'); if(wl_hash===null||wl_hash===undefined||wl_hash===''){ wl_hash=''; } if(cookie_hash===null||cookie_hash===undefined||cookie_hash===''){ cookie_hash=''; } if(wl_hash&&( wl_created===null||wl_created===undefined||wl_created==='' )){ throw 'No wishlist_created'; } if(wl_created){ var wl_expiration=1 * cart_created + day_in_ms, timestamp_now=( new Date() ).getTime(); if(cart_expiration < timestamp_now){ throw 'Fragment expired'; } wl_timeout=setTimeout(refresh_wl_fragment, ( wl_expiration - timestamp_now )); } if(wl_fragments&&wl_fragments['div.widget_wishlist_content']&&wl_hash===cookie_hash){ $.each(wl_fragments, function(key, value){ $(key).replaceWith(value); }); $(document.body).trigger('wl_fragments_loaded'); }else{ throw 'No fragment'; }} catch(err){ refresh_wl_fragment(); }}else{ refresh_wl_fragment(); }}; var events=function (){ $wishlist.each(function (){ var $this=$(this); $this.on('click', '>.toggle', function(e){ e.preventDefault(); if(!$this.hasClass('wishlist-open')){ openWishlist($this); }else{ closeWishlist($this); }}); }); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.header-wishlist'); if(!$target.length){ closeWishlist(); }}); $body.on('added_to_wishlist wl_fragments_refreshed wl_fragments_loaded', function (){ initUndoAction(); initRemoveAction(); initAddToCartAction(); itemsCount=parseInt($wishlist.first().find('.wishlist-count').text()); $wishlist.find('.product_list_widget').perfectScrollbar({ suppressScrollX: true }); }); $window.on('resize', function (){ tmRobin.setTopValue($dropDown); }); }; wlFragments(); events(); var openWishlist=function($el){ $el.addClass('wishlist-open'); if($dropDown.css('position')=='fixed'){ $body.addClass('mobile-wishlist-opened'); $el.find('.close-on-mobile').on('click', function(e){ e.preventDefault(); closeWishlist($el); }); tmRobin.setTopValue($dropDown); }}; var closeWishlist=function($el){ if(typeof $el=='undefined'){ $wishlist.removeClass('wishlist-open'); }else{ $el.removeClass('wishlist-open'); } if($dropDown.css('position')=='fixed'){ $body.removeClass('mobile-wishlist-opened'); }}; var initUndoAction=function (){ $wishlist.find('.undo').on('click', 'a', function(e){ e.preventDefault(); var $item=$wishlist.find('.wishlist_item.deleted'); var product_id=$item.data('product_id'); $item.addClass('undo-deleted') .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (){ $(this) .off('webkitAnimationEnd oanimationend msAnimationEnd animationend') .removeClass('deleted undo-deleted') .removeAttr('style'); }); var $wlButtons=$('.yith-wcwl-add-to-wishlist.add-to-wishlist-' + product_id); if($wlButtons.length){ $wlButtons.find('.yith-wcwl-add-button') .show() .removeClass('show') .addClass('hide'); $wlButtons.find('.yith-wcwl-wishlistaddedbrowse') .hide() .removeClass('hide') .addClass('show'); $wlButtons.find('.yith-wcwl-wishlistexistsbrowse') .hide() .removeClass('show') .addClass('hide'); } $.each(deletedItems, function(idx, item){ if(item['remove_from_wishlist']==product_id){ deletedItems.splice(idx, 1); }}); $(this).parent().removeClass('visible'); $wishlist.find('.wishlist-count').text(++itemsCount); }); }; var initRemoveAction=function (){ $wishlist.find('.wishlist_item .remove').on('click', function(e){ e.preventDefault(); var $parent=$(this).parent(), product_id=$parent.data('product_id'), wishlistID=$parent.data('wishlist_id'), wishlistToken=$parent.data('wishlist_token'), data={ remove_from_wishlist: product_id, wishlist_id:wishlistID, wishlist_token:wishlistToken, }, $parents=$wishlist.find('.wishlist_item[data-product_id="' + product_id + '"]'); clearInterval(undoTimeout); $wishlist.find('.wishlist_item.deleted').remove(); $parents.addClass('loading'); setTimeout(function (){ $parents.removeClass('loading').addClass('deleted'); deletedItems.push(data); var $wlButtons=$('.yith-wcwl-add-to-wishlist.add-to-wishlist-' + product_id); if($wlButtons.length){ $wlButtons.find('.yith-wcwl-add-button') .show() .removeClass('hide') .addClass('show'); $wlButtons.find('.yith-wcwl-wishlistaddedbrowse') .hide() .removeClass('show') .addClass('hide'); $wlButtons.find('.yith-wcwl-wishlistexistsbrowse') .hide() .removeClass('show') .addClass('hide'); $wlButtons.find('.add_to_wishlist').removeClass('loading'); } $wishlist.find('.wishlist-count').text(--itemsCount); if(!removeImmediately){ $wishlist.find('.undo').addClass('visible'); }else{ removeItemsAjax(); }}, 500); if(!removeImmediately){ undoTimeout=setTimeout(function (){ $wishlist.find('.undo').removeClass('visible'); removeItemsAjax(); }, 5000); }}); }; var initAddToCartAction=function (){ $wishlist.find('.add_to_cart_button.product_type_simple').on('click', function (){ if($wishlist.find('.remove_after_add_to_cart').length){ removeImmediately=true; $wishlist.find('.add_to_cart_button').addClass('inactive'); $wishlist.find('.remove').addClass('inactive'); $(this).removeClass('inactive'); $(this).closest('.wishlist_item').find('.remove').trigger('click'); }}); }; var removeItemsAjax=function (){ var data={ action: 'tm_robin_remove_wishlist_items', items:deletedItems, }; $.ajax({ method:'POST', url:tmRobinConfigs.ajax_url, data:data, success: function(response){ tmRobin.updateWishListFragments(); clearInterval(undoTimeout); $wishlist.find('.add_to_cart_button').removeClass('inactive'); $wishlist.find('.remove').removeClass('inactive'); removeImmediately=false; deletedItems=[]; }, error:function(error){ console.log(error); }, }); };}, updateWishListFragments: function (){ $body.trigger('wl_fragment_refresh'); $body.trigger('wl_fragment_refreshed'); }, miniCart: function (){ var $minicart=$('.header-minicart'), $dropDown=$minicart.find('.minicart-dropdown-wrapper'), symbol=$minicart.first() .find('.minicart-total .woocommerce-Price-currencySymbol') .text(), itemsCount=0, cartTotal=0, favicon, undoTimeout, deletedItems=[], minicart_opened=Cookies.get('tm_robin_minicart_favico_opened'); if(tmRobinConfigs.shop_add_to_cart_favico_on){ favicon=new Favico({ animation: 'none', bgColor:tmRobinConfigs.shop_favico_badge_bg_color, textColor: tmRobinConfigs.shop_favico_badge_text_color, }); } var events=function (){ var initEvents=function (){ initRemoveAction(); initUndoAction(); itemsCount=parseInt($minicart.first() .find('.minicart-items-count') .text()); cartTotal=parseFloat($minicart.first().find('.minicart-total') .text() .replace(symbol, '') .replace(tmRobinConfigs.wc_price_thousand_sep, '') .replace(tmRobinConfigs.wc_price_decimal_sep, '.')); $minicart.find('.product_list_widget').perfectScrollbar({ suppressScrollX: true }); if(minicart_opened=='yes'){ favicon.badge(0); }}; $minicart.each(function (){ var $this=$(this); $this.on('click', '>.toggle', function(e){ e.preventDefault(); if(!$this.hasClass('minicart-open')){ openMiniCart($this); }else{ closeMiniCart($this); }}); }); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.header-minicart'); if(!$target.length){ closeMiniCart(); }}); tmRobin.updateCartFragments(); $body.on('added_to_cart wc_fragments_refreshed wc_fragments_loaded', function (){ initEvents(); if(tmRobinConfigs.shop_add_to_cart_favico_on&&minicart_opened!='yes'){ favicon.badge(itemsCount); }}); $body.on('added_to_cart', function (){ if(tmRobinConfigs.shop_add_to_cart_favico_on){ favicon.badge(itemsCount); Cookies.set('tm_robin_minicart_favico_opened', 'no', { expires: 1, path:'/', }); }}); $document.on('cbox_closed', function (){ tmRobin.updateCartFragments(); }); $window.on('resize', function (){ tmRobin.setTopValue($dropDown); }); }; var openMiniCart=function($el){ $el.addClass('minicart-open'); if($dropDown.css('position')=='fixed'){ $body.addClass('mobile-minicart-opened'); $el.find('.close-on-mobile').on('click', function(e){ e.preventDefault(); closeMiniCart($el); }); } if(tmRobinConfigs.shop_add_to_cart_favico_on){ favicon.badge(0); Cookies.set('tm_robin_minicart_favico_opened', 'yes', { expires: 1, path:'/', }); } tmRobin.setTopValue($dropDown); }; var closeMiniCart=function($el){ if(typeof $el=='undefined'){ $minicart.removeClass('minicart-open'); }else{ $el.removeClass('minicart-open'); } if($dropDown.css('position')=='fixed'){ $body.removeClass('mobile-minicart-opened'); }}; var initRemoveAction=function (){ $minicart.find('.mini_cart_item .remove').on('click', function(e){ e.preventDefault(); var $this=$(this), cart_item_key=$this.attr('data-cart_item_key'), $links=$minicart.find('.remove[data-cart_item_key="' + cart_item_key + '"]'), $parents=$links.parent(); clearInterval(undoTimeout); $minicart.find('.mini_cart_item.deleted').remove(); $parents.addClass('loading'); setTimeout(function (){ $parents.removeClass('loading').addClass('deleted'); deletedItems.push($this.attr('data-cart_item_key')); $minicart.find('.undo').addClass('visible'); updateCart($this.parent(), false); }, 500); undoTimeout=setTimeout(function (){ $minicart.find('.undo').removeClass('visible'); removeItemsAjax(); }, 5000); }); }; var removeItemsAjax=function (){ $.ajax({ type:'POST', dataType: 'json', url:tmRobinConfigs.ajax_url, data:{ action: 'tm_robin_remove_cart_items', items:deletedItems, }, success:function(response){ tmRobin.updateCartFragments(); deletedItems=[]; clearInterval(undoTimeout); }, error:function(error){ console.log(error); }, }); }; var initUndoAction=function (){ $minicart.find('.undo').on('click', 'a', function(e){ e.preventDefault(); var $item=$minicart.find('.mini_cart_item.deleted'); $item.addClass('undo-deleted') .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (){ $(this) .off('webkitAnimationEnd oanimationend msAnimationEnd animationend') .removeClass('deleted undo-deleted') .removeAttr('style'); }); var cartItemKey=$item.find('.remove').data('cart_item_key'); deletedItems.splice(deletedItems.indexOf(cartItemKey), 1); $(this).parent().removeClass('visible'); updateCart($item, true); }); }; var updateCart=function($el, undo){ var $quantity=$el.find('.quantity'), $amount=$quantity.find('.amount'), $symbol=$amount.find('.woocommerce-Price-currencySymbol'), $symbolHTML=$symbol.html(), str=$quantity.text(), arr=[]; if(typeof str!='undefined'&&str){ arr=str.split('×'); } if(arr.length){ var qty=parseInt(arr[0]); var price=0; if($amount.length&&$symbol.length){ var t=$amount.text() .replace(symbol, '') .replace(tmRobinConfigs.wc_price_thousand_sep, '') .replace(tmRobinConfigs.wc_price_decimal_sep, '.'); price=parseFloat(t); if(!isNaN(qty)&&!isNaN(price)){ if(undo){ itemsCount +=qty; cartTotal +=qty * price; }else{ itemsCount -=qty; cartTotal -=qty * price; if(itemsCount < 0){ itemsCount=0; } if(cartTotal < 0){ cartTotal=0; }} }} } $minicart.find('.minicart-items-count').text(itemsCount); $minicart.find('.minicart-total .amount') .html($symbolHTML + formatNumber(cartTotal, tmRobinConfigs.wc_price_num_decimals)); $minicart.find('.total .amount') .html($symbolHTML + formatNumber(cartTotal, tmRobinConfigs.wc_price_num_decimals)); if(tmRobinConfigs.shop_add_to_cart_favico_on){ favicon.badge(itemsCount); Cookies.set('tm_robin_minicart_favico_opened', 'no', { expires: 1, path:'/', }); }}; var formatNumber=function(n, dp){ var w=n.toFixed(dp), k=w | 0, b=n < 0 ? 1:0, u=Math.abs(w - k), d=( '' + u.toFixed(dp) ).substr(2, dp), s='' + k, i=s.length, r=''; while(( i -=3 ) > b){ r=tmRobinConfigs.wc_price_thousand_sep + s.substr(i, 3) + r; } return s.substr(0, i + 3) + r + ( d ? tmRobinConfigs.wc_price_decimal_sep + d:'' ); }; events(); }, updateCartFragments: function (){ $body.trigger('wc_fragment_refresh'); $body.trigger('wc_fragments_refreshed'); }, shop: function (){ var categoriesCarousel=function (){ var itemCount=$('.categories-carousel').data('carousel'); $('.categories-carousel').slick({ slidesToShow:itemCount, slidesToScroll: itemCount, infinite:true, arrows:false, dots:true, responsive:[ { breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ centerMode:true, slidesToShow:1, slidesToScroll: 1, }, }, ], }); } var categoriesMenu=function (){ var $menu=$('.product-categories-menu'); if($window.width() > 991){ var w=0; $menu.find('li').each(function (){ w +=$(this)[0].getBoundingClientRect().width; }); $menu.width(Math.round(w) + 5); $menu.parent().perfectScrollbar({ suppressScrollY: true }); }else{ $menu.perfectScrollbar(); } $body.on('click', '.show-categories-menu', function(e){ e.preventDefault(); var $this=$(this); if($menu.hasClass('open')){ $this.removeClass('open'); $menu.removeClass('open').slideUp(200); }else{ $this.addClass('open'); $menu.addClass('open').slideDown(200); var scrollTo=$this.offset().top; if(tmRobinConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar') .css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo, }, 600); }}); }; var wooCategoriesToggle=function (){ if(!tmRobinConfigs.categories_toggle){ return; } $('.widget_product_categories .product-categories').addClass('has-toggle'); if($('.widget_product_categories ul li ul.children').length){ $('.widget_product_categories ul li ul.children') .parent('li') .prepend(''); } $('.widget_product_categories ul li.cat-parent i').on('click', function (){ var $parent=$(this).parent(); if($parent.hasClass('expand')){ $parent.removeClass('expand').children('ul.children').slideUp(200); }else{ $parent.addClass('expand').children('ul.children').slideDown(200); }}); $('.widget_product_categories ul li.cat-parent').each(function (){ if($(this).hasClass('current-cat')||$(this) .hasClass('current-cat-parent')){ $(this).addClass('expand').children('ul.children').show(); }else{ $(this).children('ul.children').hide(); } $('.widget_product_categories li.cat-parent.expand').find('> ul.children').show(); }); }; var wooPriceSlider=function (){ if(typeof woocommerce_price_slider_params==='undefined'){ return false; } $('input#min_price, input#max_price').hide(); $('.price_slider, .price_label').show(); var $products=$('.products'), min_price=$('.price_slider_amount #min_price').data('min'), max_price=$('.price_slider_amount #max_price').data('max'), current_min_price=parseInt(min_price, 10), current_max_price=parseInt(max_price, 10); if(typeof $products!='undefined'&&typeof $products.attr('data-min_price')!='undefined'&&$products.attr('data-min_price').length){ current_max_price=parseInt($products.attr('data-min_price'), 10); } if(typeof $products!='undefined'&&typeof $products.attr('data-max_price')!='undefined'&&$products.attr('data-max_price').length){ current_max_price=parseInt($products.attr('data-max_price'), 10); } $('.price_slider').slider({ range:true, animate: true, min:min_price, max:max_price, values:[ current_min_price, current_max_price, ], create:function (){ $('.price_slider_amount #min_price') .val(current_min_price); $('.price_slider_amount #max_price') .val(current_max_price); $(document.body) .trigger('price_slider_create', [ current_min_price, current_max_price, ]); }, slide:function(event, ui){ $('input#min_price').val(ui.values[0]); $('input#max_price').val(ui.values[1]); $(document.body) .trigger('price_slider_slide', [ ui.values[0], ui.values[1], ]); }, change:function(event, ui){ $(document.body) .trigger('price_slider_change', [ ui.values[0], ui.values[1], ]); }, }); setTimeout(function (){ $(document.body) .trigger('price_slider_create', [ current_min_price, current_max_price, ]); }, 10); }; var productClass=function (){ $('.products').each(function (){ var $firstProduct=$(this).find('.product').first(), $product=$(this).find('.product'), productWidth=Math.round($firstProduct.outerWidth()), windowWidth=$window.width(), minWidth=155, extraSmallWidth=150, maxWidth=300, extraLargeWidth=600; if(windowWidth > 768){ minWidth=240; } if(windowWidth > 992){ extraSmallWidth=234; minWidth=235; } if(windowWidth > 1200){ extraSmallWidth=200; minWidth=270; } if(productWidth < minWidth){ $product.addClass('small-product'); }else{ $product.removeClass('small-product'); } if(productWidth < extraSmallWidth){ $product.addClass('extra-small-product'); }else{ $product.removeClass('extra-small-product'); } if(windowWidth > 1200&&productWidth > maxWidth&&$product.hasClass('col-xl-4')){ $product.addClass('large-product'); }else{ $product.removeClass('large-product'); } if(windowWidth > 1200&&productWidth > extraLargeWidth&&( $product.hasClass('col-xl-6')||$product.hasClass('col-xl-1') )){ $product.addClass('extra-large-product'); }else{ $product.removeClass('extra-large-product'); }}); }; var events=function (){ $('.shop-filter select.orderby').niceSelect(); $('.product-categories-select .list').perfectScrollbar(); $('.widget_tm_layered_nav ul.show-display-list').perfectScrollbar(); categoriesCarousel(); categoriesMenu(); wooCategoriesToggle(); wooPriceSlider(); gridListSwitcher(); columnSwitcher(); filterDropdowns(); setTimeout(function (){ productClass(); }, 500); }; var initAfterAjax=function (){ events(); $('.woocommerce-ordering').on('change', 'select.orderby', function (){ $(this).closest('form').submit(); }); tmRobin.reInitSwatches(); }; var ajaxShop=function (){ if(!tmRobinConfigs.shop_ajax_on){ return; } var ajaxLinks='.woocommerce-pagination a, .product-categories-menu a, .shop-loop-head a, .widget_product_categories a, .widget_tm_layered_nav a, .widget_layered_nav_filters a', scrollToTop=function (){ $body.stop().animate({ scrollTop: $('.main-container').offset().top - 100, }, 400); }; $body.on('click', '.woocommerce-pagination a', function (){ scrollToTop(); }); $document.pjax(ajaxLinks, '.main-container', { timeout:5000, scrollTo: false, fragment: '.main-container', }); $document.on('click', '.widget_price_filter form .button', function (){ var form=$('.widget_price_filter form'); $.pjax({ container: '.main-container', fragment:'.main-container', timeout:4000, url:form.attr('action'), data:form.serialize(), scrollTo:false, }); return false; }); $document.on('pjax:error', function(xhr, textStatus, error, options){ console.log('pjax error ' + error); }); $document.on('pjax:start', function(xhr, options){ $body.addClass('ajax-loading'); }); $document.on('pjax:complete', function(xhr, textStatus, options){ initAfterAjax(); scrollToTop(); $body.removeClass('ajax-loading'); }); $document.on('pjax:end', function(xhr, textStatus, options){ $body.removeClass('ajax-loading'); }); $document.on('yith-wcan-ajax-loading', function (){ var $yit_wcan=$('.yit-wcan-container'); if($yit_wcan.length){ scrollToTop(); }}); }; var shopMasonry=function (){ var $products=$('.archive.woocommerce.post-type-archive-product .products.grid, .archive.woocommerce.tax-product_cat .products.grid'); $products.isotope({ layoutMode:'fitRows', itemSelector:'.product', transitionDuration: 400, }).imagesLoaded().progress(function (){ $products.isotope('layout'); }); }; var gridListSwitcher=function (){ $('#switch-view-grid').unbind('click').on('click', function (){ $(this).addClass('active'); $('.col-switcher').removeClass('hidden'); $('#switch-view-list').removeClass('active'); if('list'==Cookies.get('tm_robin_archive_view_mode')){ var $toggle=$('.switch-view'); if($toggle.length){ var $parent=$toggle.closest('.shop-loop-head'), $products=$parent.next(); if($('.yit-wcan-container').length){ $products=$('.yit-wcan-container').find('.products'); } $products.fadeOut(300, function (){ $products.addClass('grid').removeClass('list').fadeIn(300); }); setTimeout(function (){ shopMasonry(); productClass(); }, 500); }} Cookies.set('tm_robin_archive_view_mode', 'grid', { path: '/' }); return false; }); $('#switch-view-list').on('click', function (){ $(this).addClass('active'); $('.col-switcher').addClass('hidden'); $('#switch-view-grid').removeClass('active'); if('grid'==Cookies.get('tm_robin_archive_view_mode')){ var $toggle=$('.switch-view'); if($toggle.length){ var $parent=$toggle.closest('.shop-loop-head'), $products=$parent.next(); if($('.yit-wcan-container').length){ $products=$('.yit-wcan-container').find('.products'); } $products.fadeOut(300, function (){ $products.addClass('list').removeClass('grid').fadeIn(300); }); }} Cookies.set('tm_robin_archive_view_mode', 'list', { path: '/' }); $products.isotope('destroy'); return false; }); if(Cookies.get('tm_robin_archive_view_mode')){ var $toggle=$('.switch-view'); if($toggle.length){ var $parent=$toggle.closest('.shop-loop-head'), $products=$parent.next(); if($('.yit-wcan-container').length){ $products=$('.yit-wcan-container').find('.products'); } if($products.hasClass('grid')){ Cookies.set('tm_robin_archive_view_mode', 'grid', { path: '/' }); }else if($products.hasClass('list')){ $('.col-switcher').addClass('hidden'); Cookies.set('tm_robin_archive_view_mode', 'list', { path: '/' }); $products.isotope('destroy'); }else{ $products.addClass(Cookies.set('tm_robin_archive_view_mode')); }} } if(Cookies.get('tm_robin_archive_view_mode')=='grid'){ $('.col-switcher').removeClass('hidden'); $('.switch-view #switch-view-grid').addClass('active'); $('.switch-view #switch-view-list').removeClass('active'); } if(Cookies.get('tm_robin_archive_view_mode')=='list'){ $('.col-switcher').addClass('hidden'); $('.switch-view #switch-view-list').addClass('active'); $('.switch-view #switch-view-grid').removeClass('active'); if($window.width() < 768){ $('.products').removeClass('list').addClass('grid'); $('.col-switcher').removeClass('hidden'); setTimeout(function (){ shopMasonry(); productClass(); }, 500); }else{ $('.products').removeClass('grid').addClass('list'); $('.products').isotope('destroy'); $('.col-switcher').addClass('hidden'); } if($('.products').closest('.tm-shortcode').length||$('.products') .closest('.up-sells').length||$('.products') .closest('.cross-sells').length||$('.products') .closest('.related').length){ $('.products').removeClass('list').addClass('grid'); }} if(Cookies.get('tm_robin_archive_view_mode')==null){ var $toggle=$('.switch-view'); if($toggle.length){ var $parent=$toggle.closest('.shop-loop-head'), $products=$parent.next(); if($('.yit-wcan-container').length){ $products=$('.yit-wcan-container').find('.products'); } $products.addClass('grid'); } $('.switch-view #switch-view-grid').addClass('active'); $('.col-switcher').removeClass('hidden'); Cookies.set('tm_robin_archive_view_mode', 'grid', { path: '/' }); }}; var addActiveClassforColSwitcher=function (){ var $colSwitcher=$('.col-switcher'); if(!$colSwitcher.length){ return; } var windowWidth=$window.width(), cols=JSON.parse($colSwitcher.attr('data-cols')), col=0; $colSwitcher.find('a').removeClass('active'); if(windowWidth <=544){ col=parseInt(cols.xs); }else if(windowWidth >=545&&windowWidth <=767){ col=parseInt(cols.sm); }else if(windowWidth >=768&&windowWidth <=991){ col=parseInt(cols.md); }else if(windowWidth >=992&&windowWidth <=1199){ col=parseInt(cols.lg); }else if(windowWidth >=1200){ col=parseInt(cols.xl); } $colSwitcher.find('a[data-col="' + col + '"]').addClass('active'); }; var columnSwitcher=function (){ if(!$('.col-switcher').length){ return; } addActiveClassforColSwitcher(); var $colSwitcher=$('.col-switcher'), $toggle=$colSwitcher.find('i'), $products=$('.archive.woocommerce.post-type-archive-product .products .product, .archive.woocommerce.tax-product_cat .products .product'); $toggle.unbind('click').on('click', function (){ if($colSwitcher.hasClass('open')){ $colSwitcher.removeClass('open'); $toggle.removeClass('fa-angle-right').addClass('fa-eye'); }else{ $colSwitcher.addClass('open'); $toggle.removeClass('fa-eye').addClass('fa-angle-right'); }}); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.col-switcher'); if(!$target.length){ $colSwitcher.removeClass('open'); $toggle.removeClass('fa-angle-right').addClass('fa-eye'); }}); setTimeout(function (){ shopMasonry(); }, 500); $colSwitcher.find('a').unbind('click').on('click', function(e){ e.preventDefault(); var $this=$(this), windowWidth=$window.width(), col=$this.attr('data-col'), removeClasses='', addClasses=''; if(0==12 % col){ col=12 / col; }else{ if(5==col){ col='is-5'; }} $colSwitcher.find('a').removeClass('active'); $this.addClass('active'); if(windowWidth <=544){ removeClasses='col-xs-2 col-xs-3 col-xs-4 col-xs-is-5 col-xs-6 col-xs-12'; addClasses='col-xs-' + col; }else if(windowWidth >=545&&windowWidth <=767){ removeClasses='col-sm-2 col-sm-3 col-sm-4 col-sm-is-5 col-sm-6 col-sm-12'; addClasses='col-sm-' + col; }else if(windowWidth >=768&&windowWidth <=991){ removeClasses='col-md-2 col-md-3 col-md-4 col-md-is-5 col-md-6 col-md-12'; addClasses='col-md-' + col; }else if(windowWidth >=992&&windowWidth <=1199){ removeClasses='col-lg-2 col-lg-3 col-lg-4 col-lg-is-5 col-lg-6 col-lg-12'; addClasses='col-lg-' + col; }else if(windowWidth >=1200){ removeClasses='col-xl-2 col-xl-3 col-xl-4 col-xl-is-5 col-xl-6 col-xl-12'; addClasses='col-xl-' + col; } $products.removeClass(removeClasses).addClass(addClasses); shopMasonry(); productClass(); }); }; var filterDropdowns=function (){ $('.widget_tm_layered_nav').on('change', 'select', function (){ var slug=$(this).val(), href=$(this) .attr('data-filter-url') .replace('TM_ROBIN_FILTER_VALUE', slug), pseudoLink=$(this).siblings('.filter-pseudo-link'); pseudoLink.attr('href', href); pseudoLink.trigger('click'); }); }; events(); ajaxShop(); $window.on('popstate', function (){ wooCategoriesToggle(); categoriesMenu(); gridListSwitcher(); columnSwitcher(); tmRobin.reInitSwatches(); }); $window.on('resize', function (){ if(Cookies.get('tm_robin_archive_view_mode')=='list'){ if($window.width() < 768){ $('.products').removeClass('list').addClass('grid'); $('.col-switcher').removeClass('hidden'); setTimeout(function (){ shopMasonry(); productClass(); }, 500); }else{ $('.products').removeClass('grid').addClass('list'); $('.products').isotope('destroy'); $('.col-switcher').addClass('hidden'); }} if($('.products').closest('.tm-shortcode').length||$('.products') .closest('.up-sells').length||$('.products') .closest('.cross-sells').length||$('.products') .closest('.related').length){ $('.products').removeClass('list').addClass('grid'); } productClass(); addActiveClassforColSwitcher(); }); }, quickView: function (){ var events=function (){ var disable=false, sliderFinalWidth=tmRobinConfigs.quickview_image_width, maxQuickWidth=960; $body.on('click', '.quick-view-btn', function(e){ e.preventDefault(); if(disable){ return false; } var $this=$(this), $productThumb=$this.closest('.product-thumb'); if(Cookies.get('tm_robin_archive_view_mode')=='list'){ $productThumb=$this.closest('.product').find('.product-thumb'); } if(!$productThumb.length){ return; } var pid=$this.attr('data-pid'), selectedImage=$productThumb.find('img.wp-post-image'); $this.addClass('loading'); $productThumb.addClass('loading'); disable=true; $.ajax({ url:tmRobinConfigs.ajax_url, data:{ action: 'tm_robin_quick_view', pid:pid, }, timeout: 10000, success: function(response){ $('#woo-quick-view').empty().html(response); if($('#woo-quick-view').hasClass('animated-quick-view')){ $body.addClass('quick-view-opened'); animateQuickView(selectedImage, sliderFinalWidth, maxQuickWidth, 'open'); }else{ $.magnificPopup.open({ items:{ src: $('#woo-quick-view'), }, mainClass: 'mfp-fade', type:'inline', callbacks: { open:function (){ $('.quick-view-carousel') .slick({ infinite: false, dots:true, }); }, afterClose: function (){ if($('.quick-view-carousel img').length > 1){ $('.quick-view-carousel') .slick('unslick'); }}, }, }); } $this.removeClass('loading'); $productThumb.removeClass('loading'); disable=false; $('#woo-quick-view .summary') .perfectScrollbar({ suppressScrollX: true }); tmRobin.reInitSwatches(); tmRobin.quantityField(); }, error:function(error){ console.log(error); $this.removeClass('loading'); $productThumb.removeClass('loading'); disable=false; }, }); }); $body.on('click', function(e){ if($(e.target).is('.quick-view-close')||$(e.target) .is('body.quick-view-opened #page-container')){ closeQuickView(sliderFinalWidth, maxQuickWidth); }}); $document.keyup(function(event){ if(event.which=='27'){ closeQuickView(sliderFinalWidth, maxQuickWidth); }}); $window.on('resize', function (){ if($('#woo-quick-view').hasClass('is-visible')){ window.requestAnimationFrame(resizeQuickView); }}); }; var resizeQuickView=function (){ var quickViewLeft=( $window.width() - $('#woo-quick-view') .width() ) / 2, quickViewTop=( $window.height() - $('#woo-quick-view') .height() ) / 2; $('#woo-quick-view').css({ 'top':quickViewTop, 'left': quickViewLeft, }); if($('.quick-view-carousel img').length > 1&&$('.quick-view-carousel') .hasClass('slick-slider')){ $('.quick-view-carousel').slick('setPosition'); }}; var closeQuickView=function(finalWidth, maxQuickWidth){ var selectedImage=$('.empty-box').find('.woocommerce-LoopProduct-link img'); if($('.quick-view-carousel img').length > 1){ $('.quick-view-carousel').slick('unslick'); } if(!$('#woo-quick-view').hasClass('velocity-animating')&&$('#woo-quick-view') .hasClass('add-content')){ animateQuickView(selectedImage, finalWidth, maxQuickWidth, 'close'); }else{ if(typeof selectedImage!='undefined'){ closeNoAnimation(selectedImage); }} }; var closeNoAnimation=function(image){ var parentListItem=image.parents('li'); if(typeof image.offset()=='undefined'){ return; } var topSelected=image.offset().top - $window.scrollTop(), leftSelected=image.offset().left, widthSelected=image.width(); $body.removeClass('overlay-layer'); parentListItem.removeClass('empty-box'); $('#woo-quick-view') .velocity('stop') .removeClass('add-content animate-width is-visible') .css({ 'top':topSelected, 'left':leftSelected, 'width': widthSelected, }); }; var animateQuickView=function(image, finalWidth, maxQuickWidth, animationType){ var parentListItem=image.parents('.product-loop'), topSelected=image.offset().top - $window.scrollTop(), leftSelected=image.offset().left, widthSelected=image.width(), windowWidth=$window.width(), windowHeight=$window.height(), finalLeft=( windowWidth - finalWidth ) / 2, finalHeight=tmRobinConfigs.quickview_image_height, finalTop=( windowHeight - finalHeight ) / 2, quickViewWidth=( windowWidth * .8 < maxQuickWidth ) ? windowWidth * .8:maxQuickWidth, quickViewLeft=( windowWidth - quickViewWidth ) / 2; if(animationType=='open'){ parentListItem.addClass('empty-box'); $('#woo-quick-view').css({ 'top':topSelected, 'left':leftSelected, 'width': widthSelected, }).velocity({ 'top':finalTop + 'px', 'left':finalLeft + 'px', 'width': finalWidth + 'px', }, 1000, 'ease', function (){ $('#woo-quick-view').addClass('animate-width').velocity({ 'left':quickViewLeft + 'px', 'width': quickViewWidth + 'px', }, 300, 'ease', function (){ if($('.quick-view-carousel img').length > 1){ $('.quick-view-carousel').slick({ infinite: false }); } $('#woo-quick-view').addClass('add-content'); }); }).addClass('is-visible'); }else{ $('#woo-quick-view').removeClass('add-content').velocity({ 'top':finalTop + 'px', 'left':finalLeft + 'px', 'width': finalWidth + 'px', }, 300, 'ease', function (){ $body.removeClass('quick-view-opened'); $('#woo-quick-view').removeClass('animate-width').velocity({ 'top':topSelected, 'left':leftSelected, 'width': widthSelected, }, 500, 'ease', function (){ $('#woo-quick-view').removeClass('is-visible'); parentListItem.removeClass('empty-box'); }); }); }}; var initAddToCart=function (){ $body.on('submit', '#woo-quick-view form.cart', function(e){ e.preventDefault(); var $this=$(this), $loading=$('#woo-quick-view .quickview-loading'), $text=$loading.find('> span'), data=$.parseParams($this.serialize()), action={ action: 'woocommerce_add_to_cart' }; $text.text(tmRobinConfigs.adding_to_cart_text); $loading.removeClass('added').removeClass('error').fadeIn(200); data.action='tm_robin_ajax_add_to_cart'; data.pid=$this.find('button[name="add-to-cart"]').val(); if($this.hasClass('variations_form')||$this.find('.group_table').length){ data.pid=data['add-to-cart']; delete data['add-to-cart']; } $this.find('.single_add_to_cart_button').blur(); $.ajax({ type:'POST', url:tmRobinConfigs.ajax_url, data:data, success: function(response){ if('undefined'!==typeof response.fragments){ $text.text(tmRobinConfigs.added_to_cart_text); $loading.addClass('added'); tmRobin.updateCartFragments(); setTimeout(function (){ $body.trigger('added_to_cart'); }, 500); }else{ $text.text(response.message); $loading.addClass('error'); $.growl.error({ location: 'tr', title:'', size:'large', message:'', }); } $('#woo-quick-view .summary').animate({ scrollTop: 0 }, 300); $loading.delay(3200).fadeOut(); }, error:function(error){ $loading.delay(3200).fadeOut(); $.growl.error({ location: 'tr', title:'', size:'large', message:'', }); console.log(error); }, }); }); }; events(); initAddToCart(); }, notification: function (){ var config={ location: 'tr', title:'', size:'large', }; var events=function (){ $body.on('click', 'a.add_to_cart_button', function (){ $('a.add_to_cart_button').removeClass('recent-added'); $(this).addClass('recent-added'); if($(this).is('.product_type_variable, .isw-ready')){ $(this).addClass('loading'); }}); $body.on('click', 'button.single_add_to_cart_button', function (){ $('button.single_add_to_cart_button').removeClass('recent-added'); $(this).addClass('recent-added'); }); $body.on('click', '.add_to_wishlist', function (){ $(this).addClass('loading'); }); }; var addToCartNotification=function (){ $body.on('added_to_cart', function (){ $('.add_to_cart_button.product_type_variable.isw-ready').removeClass('loading'); var $recentAdded=$('.add_to_cart_button.recent-added, button.single_add_to_cart_button.recent-added'), $img=$recentAdded.closest('.product-thumb').find('img.wp-post-image'), pName=$recentAdded.attr('data-product_name'); if(!$img.length){ $img=$recentAdded.closest('.wishlist_item') .find('.wishlist_item_product_image img'); } if(!$img.length){ $img=$recentAdded.closest('.summary') .prev() .find('.woocommerce-main-image img'); } setTimeout(function (){ $recentAdded.removeClass('added').removeClass('recent-added'); $recentAdded.next('.added_to_cart').remove(); }, 5000); if(typeof pName=='undefined'||pName==''){ pName=$recentAdded.closest('.summary').find('.product_title').text().trim(); } if(typeof pName!=='undefined'){ config['message']=( $img.length ? '' + pName + '':'' ) + '

' + pName + ' ' + tmRobinConfigs.added_to_cart_notification_text + ' ' + tmRobinConfigs.view_cart_notification_text + '

'; }else{ config['message'] = tmRobinConfigs.added_to_cart_text + ' ' + tmRobinConfigs.view_cart_notification_text + ''; } $.growl.notice(config); }); }; var addToWishlistNotification=function (){ $body.on('added_to_wishlist', function (){ $('#yith-wcwl-popup-message').remove(); config['message'] = '

' + tmRobinConfigs.added_to_wishlist_text + ' ' + tmRobinConfigs.browse_wishlist_text + '

'; $.growl.notice(config); }); }; events(); if(tmRobinConfigs.shop_add_to_cart_notification_on){ addToCartNotification(); } if(tmRobinConfigs.shop_wishlist_notification_on){ addToWishlistNotification(); }}, compare: function (){ $body.on('click', '.compare-btn .compare', function (){ $(this).parent().addClass('loading'); }); $body.on('yith_woocompare_open_popup', function (){ $('.compare-btn').removeClass('loading'); $body.addClass('compare-opened'); }); $body.on('click', '#cboxClose, #cboxOverlay', function (){ $body.removeClass('compare-opened'); }); }, ajaxAddToCart: function (){ $body.on('click', '.product .summary.ajax-add-to-cart .single_add_to_cart_button', function (){ var $button=$(this); if($button.hasClass('product_type_variable')){ return true; } if($button.closest('.product-type-external').length){ return true; } if($button.hasClass('disabled')||$button.hasClass('wc-variation-selection-needed')||$button.hasClass('wc-variation-is-unavailable')){ return false; } if($document.data('processing')===1){ return false; } $document.data('processing', 1); $document.data('processing_once', 0); var $form=$button.closest('form.cart'), buttonDefaultCusor=$button.css('cursor'), data=$.parseParams($form.serialize()); if(!$form.hasClass('variations_form')&&!$form.find('.group_table').length){ data['add-to-cart']=$form.find('button[name="add-to-cart"]').val(); } $body.css('cursor', 'wait'); $button.css('cursor', 'wait').blur().addClass('loading'); console.log(data); $.ajax({ type:'POST', url:$form.attr('action'), data:data, success: function(response){ if($(response).find('.woocommerce-error').length > 0){ appendMessageDiv(response, 'woocommerce-error'); $.growl.error({ location: 'tr', title:'', size:'large', message:'', }); }else if($(response).find('.woocommerce-message').length > 0){ appendMessageDiv(response, 'woocommerce-message'); $body.trigger('added_to_cart'); tmRobin.updateCartFragments(); }else{ $document.data('processing', 0); } $document.data('processing_once', 1); $body.css('cursor', 'default'); $button.css('cursor', buttonDefaultCusor).removeClass('loading'); }, error:function(error){ console.log(error); $document.data('processing_once', 1); $document.data('processing', 0); $button.removeClass('loading'); }, }); return false; }); var isElementInViewport=function($el){ var rect=$el[0].getBoundingClientRect(); return ( rect.top >=0&&rect.left >=0&&rect.bottom <=( window.innerHeight||document.documentElement.clientHeight )&&rect.right <=( window.innerWidth||document.documentElement.clientWidth ) ); }; var getMessageParentDiv=function(response, woocommerce_msg){ var $product=$('.product.type-product:eq(0)'), $result; if($product.length > 0){ $result=$product; }else{ var id=$(response).find('.' + woocommerce_msg).parent().attr('id'); if(id){ $result=$('#' + id).children().eq($('#' + id).children().length - 1); }else{ var classes=$(response).find('' + woocommerce_msg).parent().attr('class'); $result=$document.find("div[class='" + classes + "']") .children() .eq($document.find("div[class='" + classes + "']") .children().length - 1); }} return $result.find('>.container>.row>.col-xs-12>.row'); }; var appendMessageDiv=function(response, woocommerce_msg){ var divToInsert=getMessageParentDiv(response, woocommerce_msg), message='.' + woocommerce_msg; $document.find('.woocommerce-error').remove(); $document.find('.woocommerce-message').remove(); $(divToInsert) .before($(response).find(message).wrap('
').parent().html()) .fadeIn(); var isInViewport=isElementInViewport($document.find(message)); if(!isInViewport){ var scrollTo=$(message).offset().top; if(tmRobinConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } $body.animate({ scrollTop: scrollTo - 50, }, 500); } $document.data('processing', 0); };}, ajaxLoadMore: function (){ $('.tm-loadmore-btn').on('click', function(e){ e.preventDefault(); var $loadMoreWrap=$(this).parent('.tm-loadmore-wrap'), atts=JSON.parse($loadMoreWrap.attr('data-atts')), paged=parseInt(atts.paged), posts_per_page=parseInt(atts.posts_per_page), $parent=$(atts.container), pAttr=JSON.parse($parent.attr('data-atts')), $postWrapper=atts.post_type=='post' ? $parent.find('.post-grid-layout'):$parent.find('.products'), data={ action:'tm_robin_ajax_load_more', post_type:atts.post_type, posts_per_page: posts_per_page, offset:posts_per_page * paged, columns:pAttr.columns, }; if(atts.post_type=='post'){ data.filter=pAttr.filter; data.columns=pAttr.columns; if(pAttr.filter=='category'){ data.cat_slugs=pAttr.cat_slugs; } if(pAttr.filter=='tag'){ data.tag_slugs=pAttr.tag_slugs; }} if(atts.post_type=='product'){ data.data_source=pAttr.data_source; if(pAttr.data_source=='product_attribute'){ data.attribute=pAttr.attribute; data.filter=pAttr.filter; } if(pAttr.data_source=='categories'){ data.product_cat_slugs=pAttr.product_cat_slugs; data.include_children=pAttr.include_children=='yes'; }} $.ajax({ method:'POST', url:tmRobinConfigs.ajax_url, data:data, beforeSend: function (){ $loadMoreWrap.addClass('loading'); }, success:function(response){ $loadMoreWrap.removeClass('loading'); if(response){ $postWrapper.append(response).imagesLoaded(function (){ if(atts.post_type=='post'){ tmRobin.fitVideo(); tmRobin.thumbGallery(); } $postWrapper.isotope('appended', $postWrapper.find('.adding-item')); if($postWrapper.find('.adding-item').length < posts_per_page){ $loadMoreWrap.addClass('hidden'); } atts.paged++; $loadMoreWrap.attr('data-atts', JSON.stringify(atts)); $postWrapper.find('.adding-item').removeClass('adding-item'); }); }else{ $loadMoreWrap.addClass('hidden'); }}, error:function(error){ console.log(error); }, }); }); }, product: function (){ var $mainImage=$('.woocommerce-main-image'), $images=$('.single-product .images'), $thumbs=$images.find('.thumbnails'), selectedClass='selected-image'; var thumbnails=function (){ var slickConfig={ slidesToShow: 3, responsive:[ { breakpoint: 768, settings:{ slidesToShow:3, vertical:false, verticalSwiping: false, infinite:false, arrows:false, dots:true, }, }, ], }; $thumbs.on('click', '.image-link', function(e){ e.preventDefault(); if(tmRobinConfigs.product_page_layout=='sticky'||tmRobinConfigs.product_page_layout=='sticky-fullwidth'){ openPhotoSwipe($(e.currentTarget).index() + 1); return; } var href=$(this).attr('href'), src=$(this).attr('data-single-img'), width=$(this).attr('data-width'), height=$(this).attr('data-height'), $zoomImg=$('.single-product .zoomImg'); $thumbs.find('.' + selectedClass).removeClass(selectedClass); $(this).addClass(selectedClass); $mainImage.addClass('loading-image') .attr('href', href) .find('img') .attr('src', src) .attr('srcset', src) .one('load', function (){ $mainImage.removeClass('loading-image') .data('width', width) .data('height', height); }); $zoomImg.attr('src', href); }); if(tmRobinConfigs.product_page_layout=='sticky'||tmRobinConfigs.product_page_layout=='sticky-fullwidth'){ return; } if($images.hasClass('thumbnails-left')){ slickConfig['vertical']=true; slickConfig['verticalSwiping']=true; slickConfig['adaptiveHeight']=true; }else{ slickConfig['slidesToShow']=4; } $thumbs.slick(slickConfig); }; var swatchesAndZoom=function (){ var $select=$('form.isw-swatches.variations_form') .find('select'); $select.on('change', function (){ var href=$thumbs.attr('href'), width=$thumbs.attr('data-width'), height=$thumbs.attr('data-height'), $zoomImg=$('.single-product .zoomImg'); $zoomImg.attr('src', href); }); }; var mainImage=function (){ var $lightboxBtn=$('.lightbox-btn'), $el=$mainImage; if($lightboxBtn.length){ $el=$lightboxBtn; } if($('.woocommerce-product-gallery').width() > $mainImage.find('img').data('large_image_width')){ $el=$mainImage; $lightboxBtn.addClass('hidden'); } $el.on('click', function(e){ e.preventDefault(); openPhotoSwipe(0); }); }; var openPhotoSwipe=function(index){ var pswpElement=document.querySelectorAll('.pswp')[0]; var items=getImages(); var options={ index:index, bgOpacity: 0.8, }; var gallery=new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); gallery.init(); }; var getImages=function (){ var items=[], src, width=$mainImage.data('width'), height=$mainImage.data('height'); items.push({ src: $mainImage.attr('href'), w:width, h:height, }); $thumbs.find('a').each(function (){ src=$(this).attr('href'); width=$(this).attr('data-width'); height=$(this).attr('data-height'); if(!inArray(items, src)){ items.push({ src: src, w:width, h:height, }); }}); return items; }; var inArray=function(items, src){ var i; for(i=0; i < items.length; i++){ if(items[i].src==src){ return true; }} return false; }; var scrollToReviews=function (){ if(!$('#reviews').length){ return; } $body.on('click', '.woocommerce-review-link', function(e){ e.preventDefault(); var scrollTo=$('#reviews').offset().top; if(tmRobinConfigs.sticky_header){ scrollTo -=$('.sticky-header').outerHeight() + $('.woocommerce-Reviews-title') .outerHeight(true); } $body.animate({ scrollTop: scrollTo, }, 600); }); }; var upSellsandRelated=function (){ $('.upsells .products, .related .products').slick({ slidesToShow:4, slidesToScroll: 4, dots:true, responsive:[ { breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, infinite:true, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ dots:false, adaptiveHeight: true, centerPadding:'40px', centerMode:true, slidesToShow:1, slidesToScroll: 1, }, }, ], }); }; var stickyDetails=function (){ var $details=$('.sticky-row .entry-summary'); $body.trigger('sticky_kit:recalc'); if($window.width() < 992){ return; } if(!$details.length){ return; } var rect=$images[0].getBoundingClientRect(), left=rect.right, top=60; if($('#wpadminbar').length){ top +=$('#wpadminbar').height(); } if($('.sticky-header').length){ top +=$('.sticky-header').height(); } $details.stick_in_parent({ offset_top: top }).on('sticky_kit:stick', function (){ $(this).removeClass('sticky_kit-bottom').css({ 'left': left, 'top':top, }); }).on('sticky_kit:unstick', function (){ $(this).removeClass('sticky_kit-bottom').css({ 'left': 'auto', 'top':'auto', }); }).on('sticky_kit:bottom', function (){ $(this).addClass('sticky_kit-bottom').css({ 'left': $images.outerWidth(), }); }).on('sticky_kit:unbottom', function (){ $(this).removeClass('sticky_kit-bottom').css({ 'left': left, 'top':top, }); }); }; thumbnails(); swatchesAndZoom(); mainImage(); scrollToReviews(); upSellsandRelated(); stickyDetails(); $window.scroll(function (){ var viewportHeight=$(window).height(); $images.find('.thumbnails > a').each(function (){ var offsetThumbnails=$(this).offset().top; if($window.scrollTop() > offsetThumbnails - viewportHeight + 20){ $(this).addClass('animate-images'); }}); }); $window.on('resize', function (){ stickyDetails(); }); }, crossSells: function (){ $('.cross-sells .products').slick({ slidesToShow:4, slidesToScroll: 4, dots:true, responsive:[ { breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, infinite:true, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ dots:false, adaptiveHeight: true, centerMode:true, slidesToShow:1, slidesToScroll: 1, }, }, ], }); }, swatches: function (){ $body.on('isw_change_add_to_cart_button_text', function (){ var text='', $button=$('.add_to_cart_button'); if($button.hasClass('isw-ready')){ text=isw_vars.localization['add_to_cart_text']; }else{ if($button.hasClass('isw-readmore')){ text=isw_vars.localization['read_more_text']; }else{ text=isw_vars.localization['select_options_text']; }} $button.parent().attr('aria-label', text); if($('.add_to_cart_button.isw-text-changed') .closest('.product-loop') .find('.price:not(.price-cloned)') .text().length==0){ text=isw_vars.localization['read_more_text']; $('.add_to_cart_button.isw-text-changed') .removeClass('isw-ready') .text(text) .parent() .attr('aria-label', text); }}); $body.on('isw_reset_add_to_cart_button_text', function (){ $('.add_to_cart_button.isw-text-changed') .parent() .attr('aria-label', isw_vars.localization['select_options_text']); }); }, reInitSwatches: function (){ if(typeof isw!='undefined'&&typeof isw.Swatches!=='undefined'){ isw.Swatches.init(); }}, quantityField: function (){ var build=function (){ $('div.quantity:not(.robin_qty):not(.hidden), td.quantity:not(.robin_qty):not(.hidden)') .addClass('robin_qty') .append('+') .prepend('-'); $('input.qty:not(.product-quantity input.qty)').each(function (){ var min=parseFloat($(this).attr('min')); if(min&&min > 0&&parseFloat($(this).val()) < min){ $(this).val(min); }}); $('.plus, .minus').unbind('click').on('click', function (){ var $qty=$(this).closest('.quantity').find('.qty'), currentVal=parseFloat($qty.val()), max=parseFloat($qty.attr('max')), min=parseFloat($qty.attr('min')), step=$qty.attr('step'); if(!currentVal||currentVal===''||currentVal==='NaN'){ currentVal=0; } if(max===''||max==='NaN'){ max=''; } if(min===''||min==='NaN'){ min=0; } if(step==='any'||step===''||step===undefined||parseFloat(step)==='NaN'){ step=1; } if($(this).is('.plus')){ if(max&&( max==currentVal||currentVal > max )){ $qty.val(max); }else{ $qty.val(currentVal + parseFloat(step)); }}else{ if(min&&( min==currentVal||currentVal < min )){ $qty.val(min); }else if(currentVal > 0){ $qty.val(currentVal - parseFloat(step)); }} $qty.trigger('change'); }); }; build(); $document.ajaxComplete(function (){ build(); }); }, imageCarousel: function (){ $('.tm-robin-image-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5; } var configs={ slidesToShow:parseInt(atts['number_of_images_to_show']), slidesToScroll: 1, infinite:( atts['loop']=='yes' ), autoplay:( atts['auto_play']=='yes' ), autoplaySpeed:parseInt(atts['auto_play_speed']) * 1000, adaptiveHeight: true, responsive:[ { breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, ], }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} if(parseInt(atts['number_of_images_to_show'])==1){ configs['responsive']=[ { breakpoint: 992, settings:{ adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, ]; } $this.slick(configs); $this.slick('setPosition'); if(!$this.hasClass('custom_link')){ $('.tm-carousel-item:not(.slick-cloned)').magnificPopup({ type:'image', delegate:'a', removalDelay: 300, mainClass:'mfp-fade', gallery:{ enabled: true, }, }); }}); }, testimonialCarousel: function (){ $('.tm-robin-testimonial-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5; } var configs={ infinite:( atts['loop']=='yes' ), autoplay:( atts['auto_play']=='yes' ), autoplaySpeed: parseInt(atts['auto_play_speed']) * 1000, }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.slick(configs); }); }, countdown: function (){ var equalWidthForCountdown=function (){ if(!md.mobile()&&!md.phone()&&!md.tablet()){ $('.tm-countdown, .product-countdown').each(function (){ var max_width=0; $(this).find('.countdown-section').each(function (){ var width=$(this).outerWidth(); if(width > max_width){ max_width=width; }}); $(this).find('.countdown-section').css('width', max_width); }); }}; $('.tm-robin-countdown').each(function (){ var $this=$(this), format=$this.attr('data-countdown-format'), text_singular=$this.attr('data-label-singular').split(','), text_plural=$this.attr('data-label-plural').split(','), date=new Date($this.text().trim()), server_date=new Date($this.attr('data-server-date')); if($this.is('.user-timezone')){ $this.countdown({ labels:text_plural, labels1: text_singular, format:format, until:date, onTick:function (){ equalWidthForCountdown(); }, }); }else{ $this.countdown({ labels:text_plural, labels1:text_singular, format:format, until:date, serverSync: server_date, onTick:function (){ equalWidthForCountdown(); }, }); }}); }, productCategoriesShortcode: function (){ $('.tm-robin-product-categories.categories-layout-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')), number=parseInt(atts['number_of_items_to_show']); if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5000; } var configs={ slidesToShow:number, infinite:atts['loop']=='yes', autoplay:atts['auto_play']=='yes', autoplaySpeed:parseInt(atts['auto_play_speed']), centerMode:atts['center_mode']=='yes', centerPadding:atts['center_padding'], adaptiveHeight: true, responsive:[ { breakpoint: 1199, settings:{ centerPadding: '100px', }, }, { breakpoint: 992, settings:{ slidesToShow:number - 1, slidesToScroll: 'number_of_items_to_show', centerPadding:'80px', }, }, { breakpoint: 768, settings:{ slidesToShow:( number > 2 ) ? number - 2:2, slidesToScroll: 1, centerPadding:'50px', }, }, { breakpoint: 479, settings:{ adaptiveHeight: true, arrows:true, dots:false, slidesToShow:1, centerPadding:'0px', }, }, ], }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.slick(configs); $this.slick('setPosition'); }); if(typeof( $.fn.isotope )=='undefined'||typeof ( $.fn.imagesLoaded )=='undefined'){ return; } var $catsContainer=$('.tm-robin-product-categories.categories-layout-masonry'); $catsContainer.isotope({ masonry:{ columnWidth: '.col-xl-3.category-grid-item', }, itemSelector: '.category-grid-item', }).imagesLoaded().progress(function (){ $catsContainer.isotope('layout'); }) }, productsShortCode: function (){ var productGrid=function (){ if(typeof( $.fn.isotope )=='undefined'||typeof( $.fn.imagesLoaded )=='undefined'){ return; } $('.tm-robin-products-grid').each(function (){ var $this=$(this), $products=$this.find('.products'), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(!$products.find('.tm-products-filter').length){ return; } setTimeout(function (){ $products.isotope({ layoutMode:'fitRows', itemSelector:'.product', transitionDuration: 400, }).imagesLoaded().progress(function (){ $products.isotope('layout'); }); }, 500); }); $('.tm-robin-products-grid .tm-products-filter ul') .unbind('click') .on('click', 'a', function(e){ e.preventDefault(); var $link=$(this), filterValue=$(this).attr('data-filter'); if($link.hasClass('active')){ return false; } var $ul=$link.parents('.tm-products-filter ul'); $ul.find('.active').removeClass('active'); $link.addClass('active'); $link.closest('.tm-robin-products-grid') .find('.products') .isotope({ filter: filterValue }); }); }; var productCarousel=function (){ $('.tm-robin-products-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5; } var configs={ slidesToShow:parseInt(atts['columns']), slidesToScroll: parseInt(atts['columns']), infinite:( atts['loop']==='yes' ), autoplay:( atts['auto_play']==='yes' ), autoplaySpeed:parseInt(atts['auto_play_speed']) * 1000, responsive:[ { breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 425, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'50px', slidesToShow:1, slidesToScroll: 1, }, }, { breakpoint: 375, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'30px', slidesToShow:1, slidesToScroll: 1, }, }, ], }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.find('.products').slick(configs); }); $('.tm-robin-products-carousel .tm-products-filter ul') .unbind('click') .on('click', 'a', function(e){ e.preventDefault(); var $this=$(this), filterValue=$(this).attr('data-filter'), $products=$this.closest('.tm-robin-products-carousel') .find('.products'); if($this.hasClass('active')){ return false; } var $ul=$this.parents('.tm-products-filter ul'); $ul.find('.active').removeClass('active'); $this.addClass('active'); $products.find('.slick-track').addClass('filtering').css('opacity', '0'); $products.slick('slickUnfilter').slick('slickFilter', filterValue); $products.find('.slick-track').removeClass('filtering').css('opacity', '1'); }); }; var productWidget=function (){ $('.tm-robin-products-widget') .find('.hint--left') .removeClass('hint--left') .addClass('hint--top'); $('.tm-robin-products-widget').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(atts==null){ return; } var enable_carousel=atts['enable_carousel']==='yes'; if(enable_carousel){ var $products=$this.find('.product_list_widget'); if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5; } var configs={ slidesToShow:1, slidesToScroll: 1, autoplay:( atts['auto_play']==='yes' ), autoplaySpeed:parseInt(atts['auto_play_speed']) * 1000, }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=( atts['arrows_position']=='left-right' ); configs.dots=true; } if(atts.nav_type=='arrows'){ configs.arrows=( atts.arrows_position=='left-right' ); }} $products.slick(configs); $this.find('.slick-prev.small').on('click', function (){ $products.slick('slickPrev'); }); $this.find('.slick-next.small').on('click', function (){ $products.slick('slickNext'); }); }}); }; productGrid(); productCarousel(); productWidget(); }, vcTabs: function (){ $('.vc_tta-panel').each(function (){ var $this=$(this), $carousel=$this.find('.slick-slider'); $document.on('beforeShow.vc.accordion', function (){ $this.find('.tm-products-filter').remove(); $this.find('.product').addClass('animated'); $this.css('opacity', 0); }); $document.on('afterShow.vc.accordion', function (){ window.dispatchEvent(new Event('resize')); setTimeout(function (){ $this.css('opacity', 1); $this.find('.product').removeClass('zoomOut').addClass('zoomIn'); }, 500); }); if($carousel.length&&$carousel.find('.slick-arrow').length){ $document.on('beforeShow.vc.accordion', function (){ $carousel.find('.slick-track').addClass('filtering').css('opacity', 0); }); $document.on('afterShow.vc.accordion', function (){ var $panelBody=$carousel.closest('.vc_tta-panel-body'); $panelBody.css('overflow', 'initial'); $carousel.slick('setPosition'); $carousel.find('.slick-track').removeClass('filtering').css('opacity', 1); }); }}); }, vcRow: function (){ if($window.width() < 992){ return; } var init=function (){ $('.vc_row.vc_row-robin-wide').each(function (){ var $this=$(this); if($this.attr('data-vc-full-width')!='true'||$this.attr('data-vc-stretch-content')!='true'){ return; } setTimeout(function (){ var w=$this.width(); var l=parseInt($this.css('left')); w=w * .95; l=l + w * .05 / 2; if($this.hasClass('vc_row-no-padding')){ w -=30; l +=15; } $this.css({ 'width': w, 'left':l, }); }, 500); }); }; init(); $window.on('resize', function (){ init(); }); }, cookie: function (){ if(Cookies.get('tm_robin_cookie_notice_accepted')=='yes'){ return; } var $cookieWrapper=$('.cookie-wrapper'), expires=parseInt($cookieWrapper.attr('data-expires')); setTimeout(function (){ $cookieWrapper.addClass('animated fadeInUp'); $cookieWrapper.on('click', '.cookie-accept-btn', function(e){ e.preventDefault(); $cookieWrapper.removeClass('fadeInUp').addClass('fadeOutDown'); acceptCookie(expires); }); }, 500); var acceptCookie=function(expires){ Cookies.set('tm_robin_cookie_notice_accepted', 'yes', { expires: expires, path:'/', }); };}, brand: function (){ var brandFilter=function($el){ if(typeof $el=='undefined'||!$el.length){ return; } var clazz=$el.attr('id'); $el.select2({ templateResult: function(str){ if(!str.id){ return str.text; } return $('' + str.text + ''); }, }); $el.next('.select2').on('mousedown', function (){ $('#select2-' + clazz + '-results').perfectScrollbar(); }); }; brandFilter($('select#pw_brand_category_filter')); brandFilter($('select#pw_brand_category_filter_product')); var events=function (){ $('.wb-wb-allview-letters').unbind('click').on('click', function(e){ e.preventDefault(); var full_url=this.href; var parts=full_url.split("#"), trgt=parts[1], aTag=$("div[id='" + trgt + "']"), scrollTo=aTag.offset().top; if(tmRobinConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar').css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo, }, 600); }); var $allviewCat=$('.wb-allview-robin').find('.wb-allview-cat-cnt'); $allviewCat.each(function (){ $(this) .append('' + tmRobinConfigs.go_to_filter_text + ''); }); $('.go-to-filter').on('click', function(e){ e.preventDefault(); var scrollTo=$('.wb-allview-formcnt').offset().top - 30; if(tmRobinConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar').css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo, }, 600); }); }; events(); brandFilter(); var brandsCarousel=function (){ $('.tm-robin-brands-carousel').each(function (){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts['auto_play_speed']==='undefined'||isNaN(atts['auto_play_speed'])){ atts['auto_play_speed']=5; } var configs={ slidesToShow:parseInt(atts['number']), slidesToScroll: 1, infinite:( atts['loop']=='yes' ), autoplay:( atts['auto_play']=='yes' ), autoplaySpeed:parseInt(atts['auto_play_speed']) * 1000, adaptiveHeight: true, responsive:[ { breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, ], }; if(!atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} if(parseInt(atts['number_of_images_to_show'])==1){ configs['responsive']=[ { breakpoint: 992, settings:{ adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, ]; } $this.slick(configs); $this.slick('setPosition'); }); } brandsCarousel(); }, };}() ); })(jQuery); jQuery(document).ready(function (){ tmRobin.init(); }); (function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this);